home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 25 / Cream of the Crop 25.iso / faq / wdj0597.zip / NEWCOMB.ZIP / VB / ASTEXT / WDJSEARC.FRM
Text File  |  1996-11-11  |  2KB  |  108 lines

  1. '
  2. ' WDJ Search Applet
  3. '
  4. Option Explicit
  5.  
  6.  
  7. Sub BrowseFile_Click ()
  8. '
  9. ' Select file to search
  10. '
  11.  
  12. CDialog.Flags = OFN_FILEMUSTEXIST Or OFN_HIDEREADONLY
  13. CDialog.DialogTitle = "Select File to Search"
  14. CDialog.Filter = "All Files|*.*|Text Files (*.txt)|*.txt" + _
  15.     "|C Files (*.c, *.h)|*.c;*.h"
  16. CDialog.MaxFileSize = 300
  17.  
  18. CDialog.Filename = ""       ' Make sure filename starts blank.
  19.  
  20. On Error Resume Next
  21. CDialog.Action = 1
  22. On Error GoTo 0
  23.  
  24. If CDialog.Filename <> "" Then
  25.     SrchFileName.Text = CDialog.Filename
  26.     End If
  27.  
  28. End Sub
  29.  
  30. Sub CloseApp_Click ()
  31. '
  32. ' Done
  33. '
  34.  
  35. End
  36.  
  37. End Sub
  38.  
  39. Sub Form_Load ()
  40. '
  41. ' Set up the Message Blaster
  42. '
  43.  
  44. MsgBlast.hWndTarget = WDJSearch.hWnd ' Point Blaster at this form
  45.  
  46. MsgBlast.MsgList(0) = WM_USER + 1   ' Private "Progress" message
  47. MsgBlast.MsgPassage(0) = MBLST_EAT  ' Absorb message
  48.  
  49. MsgBlast.MsgList(1) = WM_USER + 2   ' Private "Found" message
  50. MsgBlast.MsgPassage(1) = MBLST_EAT  ' Absorb message
  51.  
  52. End Sub
  53.  
  54. Sub MsgBlast_Message (MsgVal As Integer, wParam As Integer, _
  55.     lParam As Long, ReturnVal As Long)
  56. '
  57. ' Handle messages sent from DLL
  58. '
  59.  
  60. Select Case MsgVal
  61.  
  62.     Case WM_USER + 1        ' Progress message
  63.         ProgBar.Value = wParam  ' Percent-done is wParam
  64.         ProgPercent.Caption = wParam & "%"
  65.  
  66.     Case WM_USER + 2        ' "Found" message
  67.         FoundList.AddItem Format$(lParam)   ' Line found is lParam
  68.         FoundCount.Caption = Str$(FoundList.ListCount)
  69.  
  70.     End Select
  71.  
  72. DoEvents            ' Update UI
  73.  
  74. End Sub
  75.  
  76. Sub SearchCancel_Click ()
  77. '
  78. ' Cancel this search
  79. '
  80.  
  81. SrchCancel
  82.  
  83. End Sub
  84.  
  85. Sub SearchStart_Click ()
  86. '
  87. ' Start the search
  88. '
  89. Dim rc As Integer
  90.  
  91. FoundList.Clear     ' Nothing in found list
  92.  
  93. SearchCancel.Enabled = True     ' Turn on "Cancel" button
  94.  
  95. If SrchFile(WDJSearch.hWnd, SrchFileName.Text, _
  96.    SrchText.Text) = False Then
  97.     MsgBox "Search function failed!", MB_ICONEXCLAMATION, _
  98.         "WDJ Search"
  99.     End If
  100.  
  101. SearchCancel.Enabled = False    ' Turn off "Cancel" button
  102.  
  103. ProgBar.Value = 0
  104. ProgPercent.Caption = "%"
  105.  
  106. End Sub
  107.  
  108.